home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / Graphics / sKulpt / skulpt-src / d3dtypes.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-07-08  |  58.9 KB  |  1,663 lines

  1. /*==========================================================================;
  2.  *
  3.  *  Copyright (C) 1995-1998 Microsoft Corporation.  All Rights Reserved.
  4.  *
  5.  *  File:   d3dtypes.h
  6.  *  Content:    Direct3D types include file
  7.  *
  8.  ***************************************************************************/
  9.  
  10. #ifndef _D3DTYPES_H_
  11. #define _D3DTYPES_H_
  12.  
  13. #ifndef DIRECT3D_VERSION
  14. #define DIRECT3D_VERSION         0x0700
  15. #endif
  16.  
  17. /* D3DVALUE is the fundamental Direct3D fractional data type */
  18.  
  19. #define D3DVALP(val, prec) ((float)(val))
  20. #define D3DVAL(val) ((float)(val))
  21. typedef float D3DVALUE, *LPD3DVALUE;
  22. #define D3DDivide(a, b)    (float)((double) (a) / (double) (b))
  23. #define D3DMultiply(a, b)    ((a) * (b))
  24.  
  25. typedef LONG D3DFIXED;
  26.  
  27. #ifndef RGB_MAKE
  28. /*
  29.  * Format of CI colors is
  30.  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  31.  *  |    alpha      |         color index           |   fraction    |
  32.  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  33.  */
  34. #define CI_GETALPHA(ci)    ((ci) >> 24)
  35. #define CI_GETINDEX(ci)    (((ci) >> 8) & 0xffff)
  36. #define CI_GETFRACTION(ci) ((ci) & 0xff)
  37. #define CI_ROUNDINDEX(ci)  CI_GETINDEX((ci) + 0x80)
  38. #define CI_MASKALPHA(ci)   ((ci) & 0xffffff)
  39. #define CI_MAKE(a, i, f)    (((a) << 24) | ((i) << 8) | (f))
  40.  
  41. /*
  42.  * Format of RGBA colors is
  43.  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  44.  *  |    alpha      |      red      |     green     |     blue      |
  45.  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  46.  */
  47. #define RGBA_GETALPHA(rgb)      ((rgb) >> 24)
  48. #define RGBA_GETRED(rgb)        (((rgb) >> 16) & 0xff)
  49. #define RGBA_GETGREEN(rgb)      (((rgb) >> 8) & 0xff)
  50. #define RGBA_GETBLUE(rgb)       ((rgb) & 0xff)
  51. #define RGBA_MAKE(r, g, b, a)   ((D3DCOLOR) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)))
  52.  
  53. /* D3DRGB and D3DRGBA may be used as initialisers for D3DCOLORs
  54.  * The float values must be in the range 0..1
  55.  */
  56. #define D3DRGB(r, g, b) \
  57.     (0xff000000L | ( ((long)((r) * 255)) << 16) | (((long)((g) * 255)) << 8) | (long)((b) * 255))
  58. #define D3DRGBA(r, g, b, a) \
  59.     (   (((long)((a) * 255)) << 24) | (((long)((r) * 255)) << 16) \
  60.     |   (((long)((g) * 255)) << 8) | (long)((b) * 255) \
  61.     )
  62.  
  63. /*
  64.  * Format of RGB colors is
  65.  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  66.  *  |    ignored    |      red      |     green     |     blue      |
  67.  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  68.  */
  69. #define RGB_GETRED(rgb)         (((rgb) >> 16) & 0xff)
  70. #define RGB_GETGREEN(rgb)       (((rgb) >> 8) & 0xff)
  71. #define RGB_GETBLUE(rgb)        ((rgb) & 0xff)
  72. #define RGBA_SETALPHA(rgba, x) (((x) << 24) | ((rgba) & 0x00ffffff))
  73. #define RGB_MAKE(r, g, b)       ((D3DCOLOR) (((r) << 16) | ((g) << 8) | (b)))
  74. #define RGBA_TORGB(rgba)       ((D3DCOLOR) ((rgba) & 0xffffff))
  75. #define RGB_TORGBA(rgb)        ((D3DCOLOR) ((rgb) | 0xff000000))
  76.  
  77. #endif
  78.  
  79. /*
  80.  * Flags for Enumerate functions
  81.  */
  82.  
  83. /*
  84.  * Stop the enumeration
  85.  */
  86. #define D3DENUMRET_CANCEL                        DDENUMRET_CANCEL
  87.  
  88. /*
  89.  * Continue the enumeration
  90.  */
  91. #define D3DENUMRET_OK                            DDENUMRET_OK
  92.  
  93. typedef HRESULT (CALLBACK* LPD3DVALIDATECALLBACK)(LPVOID lpUserArg, DWORD dwOffset);
  94. typedef HRESULT (CALLBACK* LPD3DENUMTEXTUREFORMATSCALLBACK)(LPDDSURFACEDESC lpDdsd, LPVOID lpContext);
  95. typedef HRESULT (CALLBACK* LPD3DENUMPIXELFORMATSCALLBACK)(LPDDPIXELFORMAT lpDDPixFmt, LPVOID lpContext);
  96.  
  97. typedef DWORD D3DCOLOR, *LPD3DCOLOR;
  98.  
  99. typedef DWORD D3DMATERIALHANDLE, *LPD3DMATERIALHANDLE;
  100. typedef DWORD D3DTEXTUREHANDLE, *LPD3DTEXTUREHANDLE;
  101. typedef DWORD D3DMATRIXHANDLE, *LPD3DMATRIXHANDLE;
  102.  
  103. typedef struct _D3DCOLORVALUE {
  104.     union {
  105.     D3DVALUE r;
  106.     D3DVALUE dvR;
  107.     };
  108.     union {
  109.     D3DVALUE g;
  110.     D3DVALUE dvG;
  111.     };
  112.     union {
  113.     D3DVALUE b;
  114.     D3DVALUE dvB;
  115.     };
  116.     union {
  117.     D3DVALUE a;
  118.     D3DVALUE dvA;
  119.     };
  120. } D3DCOLORVALUE, *LPD3DCOLORVALUE;
  121.  
  122. typedef struct _D3DRECT {
  123.     union {
  124.     LONG x1;
  125.     LONG lX1;
  126.     };
  127.     union {
  128.     LONG y1;
  129.     LONG lY1;
  130.     };
  131.     union {
  132.     LONG x2;
  133.     LONG lX2;
  134.     };
  135.     union {
  136.     LONG y2;
  137.     LONG lY2;
  138.     };
  139. } D3DRECT, *LPD3DRECT;
  140.  
  141. typedef struct _D3DVECTOR {
  142.     union {
  143.     D3DVALUE x;
  144.     D3DVALUE dvX;
  145.     };
  146.     union {
  147.     D3DVALUE y;
  148.     D3DVALUE dvY;
  149.     };
  150.     union {
  151.     D3DVALUE z;
  152.     D3DVALUE dvZ;
  153.     };
  154.  
  155. public:
  156.  
  157.     // =====================================
  158.     // Constructors
  159.     // =====================================
  160.  
  161.     _D3DVECTOR() { }
  162.     _D3DVECTOR(D3DVALUE f);
  163.     _D3DVECTOR(D3DVALUE _x, D3DVALUE _y, D3DVALUE _z);
  164.     _D3DVECTOR(const D3DVALUE f[3]);
  165.  
  166.     // =====================================
  167.     // Access grants
  168.     // =====================================
  169.  
  170.     const D3DVALUE&operator[](int i) const;
  171.     D3DVALUE&operator[](int i);
  172.  
  173.     // =====================================
  174.     // Assignment operators
  175.     // =====================================
  176.  
  177.     _D3DVECTOR& operator += (const _D3DVECTOR& v);
  178.     _D3DVECTOR& operator -= (const _D3DVECTOR& v);
  179.     _D3DVECTOR& operator *= (const _D3DVECTOR& v);
  180.     _D3DVECTOR& operator /= (const _D3DVECTOR& v);
  181.     _D3DVECTOR& operator *= (D3DVALUE s);
  182.     _D3DVECTOR& operator /= (D3DVALUE s);
  183.  
  184.     // =====================================
  185.     // Unary operators
  186.     // =====================================
  187.  
  188.     friend _D3DVECTOR operator + (const _D3DVECTOR& v);
  189.     friend _D3DVECTOR operator - (const _D3DVECTOR& v);
  190.  
  191.  
  192.     // =====================================
  193.     // Binary operators
  194.     // =====================================
  195.  
  196.     // Addition and subtraction
  197.         friend _D3DVECTOR operator + (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
  198.         friend _D3DVECTOR operator - (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
  199.     // Scalar multiplication and division
  200.         friend _D3DVECTOR operator * (const _D3DVECTOR& v, D3DVALUE s);
  201.         friend _D3DVECTOR operator * (D3DVALUE s, const _D3DVECTOR& v);
  202.         friend _D3DVECTOR operator / (const _D3DVECTOR& v, D3DVALUE s);
  203.     // Memberwise multiplication and division
  204.         friend _D3DVECTOR operator * (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
  205.         friend _D3DVECTOR operator / (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
  206.  
  207.     // Vector dominance
  208.         friend int operator < (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
  209.         friend int operator <= (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
  210.  
  211.     // Bitwise equality
  212.         friend int operator == (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
  213.  
  214.     // Length-related functions
  215.         friend D3DVALUE SquareMagnitude (const _D3DVECTOR& v);
  216.         friend D3DVALUE Magnitude (const _D3DVECTOR& v);
  217.  
  218.     // Returns vector with same direction and unit length
  219.         friend _D3DVECTOR Normalize (const _D3DVECTOR& v);
  220.  
  221.     // Return min/max component of the input vector
  222.         friend D3DVALUE Min (const _D3DVECTOR& v);
  223.         friend D3DVALUE Max (const _D3DVECTOR& v);
  224.  
  225.     // Return memberwise min/max of input vectors
  226.         friend _D3DVECTOR Minimize (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
  227.         friend _D3DVECTOR Maximize (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
  228.  
  229.     // Dot and cross product
  230.         friend D3DVALUE DotProduct (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
  231.         friend _D3DVECTOR CrossProduct (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
  232.  
  233. } D3DVECTOR, *LPD3DVECTOR;
  234.  
  235. /*
  236.  * Vertex data types supported in an ExecuteBuffer.
  237.  */
  238.  
  239. /*
  240.  * Homogeneous vertices
  241.  */
  242.  
  243. typedef struct _D3DHVERTEX {
  244.     DWORD           dwFlags;        /* Homogeneous clipping flags */
  245.     union {
  246.     D3DVALUE    hx;
  247.     D3DVALUE    dvHX;
  248.     };
  249.     union {
  250.     D3DVALUE    hy;
  251.     D3DVALUE    dvHY;
  252.     };
  253.     union {
  254.     D3DVALUE    hz;
  255.     D3DVALUE    dvHZ;
  256.     };
  257. } D3DHVERTEX, *LPD3DHVERTEX;
  258.  
  259. /*
  260.  * Transformed/lit vertices
  261.  */
  262. typedef struct _D3DTLVERTEX {
  263.     union {
  264.     D3DVALUE    sx;             /* Screen coordinates */
  265.     D3DVALUE    dvSX;
  266.     };
  267.     union {
  268.     D3DVALUE    sy;
  269.     D3DVALUE    dvSY;
  270.     };
  271.     union {
  272.     D3DVALUE    sz;
  273.     D3DVALUE    dvSZ;
  274.     };
  275.     union {
  276.     D3DVALUE    rhw;        /* Reciprocal of homogeneous w */
  277.     D3DVALUE    dvRHW;
  278.     };
  279.     union {
  280.     D3DCOLOR    color;          /* Vertex color */
  281.     D3DCOLOR    dcColor;
  282.     };
  283.     union {
  284.     D3DCOLOR    specular;       /* Specular component of vertex */
  285.     D3DCOLOR    dcSpecular;
  286.     };
  287.     union {
  288.     D3DVALUE    tu;             /* Texture coordinates */
  289.     D3DVALUE    dvTU;
  290.     };
  291.     union {
  292.     D3DVALUE    tv;
  293.     D3DVALUE    dvTV;
  294.     };
  295.     _D3DTLVERTEX() { }
  296.     _D3DTLVERTEX(const D3DVECTOR& v, float _rhw,
  297.                  D3DCOLOR _color, D3DCOLOR _specular,
  298.                  float _tu, float _tv)
  299.         { sx = v.x; sy = v.y; sz = v.z; rhw = _rhw;
  300.           color = _color; specular = _specular;
  301.           tu = _tu; tv = _tv;
  302.         }
  303. } D3DTLVERTEX, *LPD3DTLVERTEX;
  304.  
  305. /*
  306.  * Untransformed/lit vertices
  307.  */
  308. typedef struct _D3DLVERTEX {
  309.     union {
  310.     D3DVALUE     x;             /* Homogeneous coordinates */
  311.     D3DVALUE     dvX;
  312.     };
  313.     union {
  314.     D3DVALUE     y;
  315.     D3DVALUE     dvY;
  316.     };
  317.     union {
  318.     D3DVALUE     z;
  319.     D3DVALUE     dvZ;
  320.     };
  321.     DWORD            dwReserved;
  322.     union {
  323.     D3DCOLOR     color;         /* Vertex color */
  324.     D3DCOLOR     dcColor;
  325.     };
  326.     union {
  327.     D3DCOLOR     specular;      /* Specular component of vertex */
  328.     D3DCOLOR     dcSpecular;
  329.     };
  330.     union {
  331.     D3DVALUE     tu;            /* Texture coordinates */
  332.     D3DVALUE     dvTU;
  333.     };
  334.     union {
  335.     D3DVALUE     tv;
  336.     D3DVALUE     dvTV;
  337.     };
  338.     _D3DLVERTEX() { }
  339.     _D3DLVERTEX(const D3DVECTOR& v,
  340.                 D3DCOLOR _color, D3DCOLOR _specular,
  341.                 float _tu, float _tv)
  342.         { x = v.x; y = v.y; z = v.z; dwReserved = 0;
  343.           color = _color; specular = _specular;
  344.           tu = _tu; tv = _tv;
  345.         }
  346. } D3DLVERTEX, *LPD3DLVERTEX;
  347.  
  348. /*
  349.  * Untransformed/unlit vertices
  350.  */
  351.  
  352. typedef struct _D3DVERTEX {
  353.     union {
  354.     D3DVALUE     x;             /* Homogeneous coordinates */
  355.     D3DVALUE     dvX;
  356.     };
  357.     union {
  358.     D3DVALUE     y;
  359.     D3DVALUE     dvY;
  360.     };
  361.     union {
  362.     D3DVALUE     z;
  363.     D3DVALUE     dvZ;
  364.     };
  365.     union {
  366.     D3DVALUE     nx;            /* Normal */
  367.     D3DVALUE     dvNX;
  368.     };
  369.     union {
  370.     D3DVALUE     ny;
  371.     D3DVALUE     dvNY;
  372.     };
  373.     union {
  374.     D3DVALUE     nz;
  375.     D3DVALUE     dvNZ;
  376.     };
  377.     union {
  378.     D3DVALUE     tu;            /* Texture coordinates */
  379.     D3DVALUE     dvTU;
  380.     };
  381.     union {
  382.     D3DVALUE     tv;
  383.     D3DVALUE     dvTV;
  384.     };
  385.     _D3DVERTEX() { }
  386.     _D3DVERTEX(const D3DVECTOR& v, const D3DVECTOR& n, float _tu, float _tv)
  387.         { x = v.x; y = v.y; z = v.z;
  388.           nx = n.x; ny = n.y; nz = n.z;
  389.           tu = _tu; tv = _tv;
  390.         }
  391. } D3DVERTEX, *LPD3DVERTEX;
  392.  
  393.  
  394. /*
  395.  * Matrix, viewport, and tranformation structures and definitions.
  396.  */
  397.  
  398. typedef struct _D3DMATRIX {
  399.     union {
  400.         struct {
  401.             D3DVALUE        _11, _12, _13, _14;
  402.             D3DVALUE        _21, _22, _23, _24;
  403.             D3DVALUE        _31, _32, _33, _34;
  404.             D3DVALUE        _41, _42, _43, _44;
  405.         } _m;
  406.         D3DVALUE m[4][4];
  407.     };
  408.     _D3DMATRIX() { }
  409.     _D3DMATRIX( D3DVALUE _m00, D3DVALUE _m01, D3DVALUE _m02, D3DVALUE _m03,
  410.                 D3DVALUE _m10, D3DVALUE _m11, D3DVALUE _m12, D3DVALUE _m13,
  411.                 D3DVALUE _m20, D3DVALUE _m21, D3DVALUE _m22, D3DVALUE _m23,
  412.                 D3DVALUE _m30, D3DVALUE _m31, D3DVALUE _m32, D3DVALUE _m33
  413.         )
  414.         {
  415.                 m[0][0] = _m00; m[0][1] = _m01; m[0][2] = _m02; m[0][3] = _m03;
  416.                 m[1][0] = _m10; m[1][1] = _m11; m[1][2] = _m12; m[1][3] = _m13;
  417.                 m[2][0] = _m20; m[2][1] = _m21; m[2][2] = _m22; m[2][3] = _m23;
  418.                 m[3][0] = _m30; m[3][1] = _m31; m[3][2] = _m32; m[3][3] = _m33;
  419.         }
  420.  
  421.     D3DVALUE& operator()(int iRow, int iColumn) { return m[iRow][iColumn]; }
  422.     const D3DVALUE& operator()(int iRow, int iColumn) const { return m[iRow][iColumn]; }
  423.     friend _D3DMATRIX operator* (const _D3DMATRIX&, const _D3DMATRIX&);
  424. } D3DMATRIX, *LPD3DMATRIX;
  425.  
  426. #include "d3dvec.inl"
  427.  
  428. typedef struct _D3DVIEWPORT {
  429.     DWORD       dwSize;
  430.     DWORD       dwX;
  431.     DWORD       dwY;        /* Top left */
  432.     DWORD       dwWidth;
  433.     DWORD       dwHeight;   /* Dimensions */
  434.     D3DVALUE    dvScaleX;   /* Scale homogeneous to screen */
  435.     D3DVALUE    dvScaleY;   /* Scale homogeneous to screen */
  436.     D3DVALUE    dvMaxX;     /* Min/max homogeneous x coord */
  437.     D3DVALUE    dvMaxY;     /* Min/max homogeneous y coord */
  438.     D3DVALUE    dvMinZ;
  439.     D3DVALUE    dvMaxZ;     /* Min/max homogeneous z coord */
  440. } D3DVIEWPORT, *LPD3DVIEWPORT;
  441.  
  442. typedef struct _D3DVIEWPORT2 {
  443.     DWORD       dwSize;
  444.     DWORD       dwX;
  445.     DWORD       dwY;        /* Viewport Top left */
  446.     DWORD       dwWidth;
  447.     DWORD       dwHeight;   /* Viewport Dimensions */
  448.     D3DVALUE    dvClipX;        /* Top left of clip volume */
  449.     D3DVALUE    dvClipY;
  450.     D3DVALUE    dvClipWidth;    /* Clip Volume Dimensions */
  451.     D3DVALUE    dvClipHeight;
  452.     D3DVALUE    dvMinZ;         /* Min/max of clip Volume */
  453.     D3DVALUE    dvMaxZ;
  454. } D3DVIEWPORT2, *LPD3DVIEWPORT2;
  455.  
  456. typedef struct _D3DVIEWPORT7 {
  457.     DWORD       dwX;
  458.     DWORD       dwY;            /* Viewport Top left */
  459.     DWORD       dwWidth;
  460.     DWORD       dwHeight;       /* Viewport Dimensions */
  461.     D3DVALUE    dvMinZ;         /* Min/max of clip Volume */
  462.     D3DVALUE    dvMaxZ;
  463. } D3DVIEWPORT7, *LPD3DVIEWPORT7;
  464.  
  465. /*
  466.  * Values for clip fields.
  467.  */
  468.  
  469. // Max number of user clipping planes, supported in D3D.
  470. #define D3DMAXUSERCLIPPLANES 32
  471.  
  472. // These bits could be ORed together to use with D3DRENDERSTATE_CLIPPLANEENABLE
  473. //
  474. #define D3DCLIPPLANE0 (1 << 0)
  475. #define D3DCLIPPLANE1 (1 << 1)
  476. #define D3DCLIPPLANE2 (1 << 2)
  477. #define D3DCLIPPLANE3 (1 << 3)
  478. #define D3DCLIPPLANE4 (1 << 4)
  479. #define D3DCLIPPLANE5 (1 << 5)
  480.  
  481. #define D3DCLIP_LEFT                0x00000001L
  482. #define D3DCLIP_RIGHT               0x00000002L
  483. #define D3DCLIP_TOP             0x00000004L
  484. #define D3DCLIP_BOTTOM              0x00000008L
  485. #define D3DCLIP_FRONT               0x00000010L
  486. #define D3DCLIP_BACK                0x00000020L
  487. #define D3DCLIP_GEN0                0x00000040L
  488. #define D3DCLIP_GEN1                0x00000080L
  489. #define D3DCLIP_GEN2                0x00000100L
  490. #define D3DCLIP_GEN3                0x00000200L
  491. #define D3DCLIP_GEN4                0x00000400L
  492. #define D3DCLIP_GEN5                0x00000800L
  493.  
  494. /*
  495.  * Values for d3d status.
  496.  */
  497. #define D3DSTATUS_CLIPUNIONLEFT         D3DCLIP_LEFT
  498. #define D3DSTATUS_CLIPUNIONRIGHT        D3DCLIP_RIGHT
  499. #define D3DSTATUS_CLIPUNIONTOP          D3DCLIP_TOP
  500. #define D3DSTATUS_CLIPUNIONBOTTOM       D3DCLIP_BOTTOM
  501. #define D3DSTATUS_CLIPUNIONFRONT        D3DCLIP_FRONT
  502. #define D3DSTATUS_CLIPUNIONBACK         D3DCLIP_BACK
  503. #define D3DSTATUS_CLIPUNIONGEN0         D3DCLIP_GEN0
  504. #define D3DSTATUS_CLIPUNIONGEN1         D3DCLIP_GEN1
  505. #define D3DSTATUS_CLIPUNIONGEN2         D3DCLIP_GEN2
  506. #define D3DSTATUS_CLIPUNIONGEN3         D3DCLIP_GEN3
  507. #define D3DSTATUS_CLIPUNIONGEN4         D3DCLIP_GEN4
  508. #define D3DSTATUS_CLIPUNIONGEN5         D3DCLIP_GEN5
  509.  
  510. #define D3DSTATUS_CLIPINTERSECTIONLEFT      0x00001000L
  511. #define D3DSTATUS_CLIPINTERSECTIONRIGHT     0x00002000L
  512. #define D3DSTATUS_CLIPINTERSECTIONTOP       0x00004000L
  513. #define D3DSTATUS_CLIPINTERSECTIONBOTTOM    0x00008000L
  514. #define D3DSTATUS_CLIPINTERSECTIONFRONT     0x00010000L
  515. #define D3DSTATUS_CLIPINTERSECTIONBACK      0x00020000L
  516. #define D3DSTATUS_CLIPINTERSECTIONGEN0      0x00040000L
  517. #define D3DSTATUS_CLIPINTERSECTIONGEN1      0x00080000L
  518. #define D3DSTATUS_CLIPINTERSECTIONGEN2      0x00100000L
  519. #define D3DSTATUS_CLIPINTERSECTIONGEN3      0x00200000L
  520. #define D3DSTATUS_CLIPINTERSECTIONGEN4      0x00400000L
  521. #define D3DSTATUS_CLIPINTERSECTIONGEN5      0x00800000L
  522. #define D3DSTATUS_ZNOTVISIBLE               0x01000000L
  523. /* Do not use 0x80000000 for any status flags in future as it is reserved */
  524.  
  525. #define D3DSTATUS_CLIPUNIONALL  (       \
  526.         D3DSTATUS_CLIPUNIONLEFT |   \
  527.         D3DSTATUS_CLIPUNIONRIGHT    |   \
  528.         D3DSTATUS_CLIPUNIONTOP  |   \
  529.         D3DSTATUS_CLIPUNIONBOTTOM   |   \
  530.         D3DSTATUS_CLIPUNIONFRONT    |   \
  531.         D3DSTATUS_CLIPUNIONBACK |   \
  532.         D3DSTATUS_CLIPUNIONGEN0 |   \
  533.         D3DSTATUS_CLIPUNIONGEN1 |   \
  534.         D3DSTATUS_CLIPUNIONGEN2 |   \
  535.         D3DSTATUS_CLIPUNIONGEN3 |   \
  536.         D3DSTATUS_CLIPUNIONGEN4 |   \
  537.         D3DSTATUS_CLIPUNIONGEN5     \
  538.         )
  539.  
  540. #define D3DSTATUS_CLIPINTERSECTIONALL   (       \
  541.         D3DSTATUS_CLIPINTERSECTIONLEFT  |   \
  542.         D3DSTATUS_CLIPINTERSECTIONRIGHT |   \
  543.         D3DSTATUS_CLIPINTERSECTIONTOP   |   \
  544.         D3DSTATUS_CLIPINTERSECTIONBOTTOM    |   \
  545.         D3DSTATUS_CLIPINTERSECTIONFRONT |   \
  546.         D3DSTATUS_CLIPINTERSECTIONBACK  |   \
  547.         D3DSTATUS_CLIPINTERSECTIONGEN0  |   \
  548.         D3DSTATUS_CLIPINTERSECTIONGEN1  |   \
  549.         D3DSTATUS_CLIPINTERSECTIONGEN2  |   \
  550.         D3DSTATUS_CLIPINTERSECTIONGEN3  |   \
  551.         D3DSTATUS_CLIPINTERSECTIONGEN4  |   \
  552.         D3DSTATUS_CLIPINTERSECTIONGEN5      \
  553.         )
  554.  
  555. #define D3DSTATUS_DEFAULT   (           \
  556.         D3DSTATUS_CLIPINTERSECTIONALL   |   \
  557.         D3DSTATUS_ZNOTVISIBLE)
  558.  
  559.  
  560. /*
  561.  * Options for direct transform calls
  562.  */
  563. #define D3DTRANSFORM_CLIPPED       0x00000001l
  564. #define D3DTRANSFORM_UNCLIPPED     0x00000002l
  565.  
  566. typedef struct _D3DTRANSFORMDATA {
  567.     DWORD           dwSize;
  568.     LPVOID      lpIn;           /* Input vertices */
  569.     DWORD           dwInSize;       /* Stride of input vertices */
  570.     LPVOID      lpOut;          /* Output vertices */
  571.     DWORD           dwOutSize;      /* Stride of output vertices */
  572.     LPD3DHVERTEX    lpHOut;         /* Output homogeneous vertices */
  573.     DWORD           dwClip;         /* Clipping hint */
  574.     DWORD           dwClipIntersection;
  575.     DWORD           dwClipUnion;    /* Union of all clip flags */
  576.     D3DRECT         drExtent;       /* Extent of transformed vertices */
  577. } D3DTRANSFORMDATA, *LPD3DTRANSFORMDATA;
  578.  
  579. /*
  580.  * Structure defining position and direction properties for lighting.
  581.  */
  582. typedef struct _D3DLIGHTINGELEMENT {
  583.     D3DVECTOR dvPosition;           /* Lightable point in model space */
  584.     D3DVECTOR dvNormal;             /* Normalised unit vector */
  585. } D3DLIGHTINGELEMENT, *LPD3DLIGHTINGELEMENT;
  586.  
  587. /*
  588.  * Structure defining material properties for lighting.
  589.  */
  590. typedef struct _D3DMATERIAL {
  591.     DWORD           dwSize;
  592.     union {
  593.     D3DCOLORVALUE   diffuse;        /* Diffuse color RGBA */
  594.     D3DCOLORVALUE   dcvDiffuse;
  595.     };
  596.     union {
  597.     D3DCOLORVALUE   ambient;        /* Ambient color RGB */
  598.     D3DCOLORVALUE   dcvAmbient;
  599.     };
  600.     union {
  601.     D3DCOLORVALUE   specular;       /* Specular 'shininess' */
  602.     D3DCOLORVALUE   dcvSpecular;
  603.     };
  604.     union {
  605.     D3DCOLORVALUE   emissive;       /* Emissive color RGB */
  606.     D3DCOLORVALUE   dcvEmissive;
  607.     };
  608.     union {
  609.     D3DVALUE        power;          /* Sharpness if specular highlight */
  610.     D3DVALUE        dvPower;
  611.     };
  612.     D3DTEXTUREHANDLE    hTexture;       /* Handle to texture map */
  613.     DWORD           dwRampSize;
  614. } D3DMATERIAL, *LPD3DMATERIAL;
  615.  
  616. typedef struct _D3DMATERIAL7 {
  617.     union {
  618.     D3DCOLORVALUE   diffuse;        /* Diffuse color RGBA */
  619.     D3DCOLORVALUE   dcvDiffuse;
  620.     };
  621.     union {
  622.     D3DCOLORVALUE   ambient;        /* Ambient color RGB */
  623.     D3DCOLORVALUE   dcvAmbient;
  624.     };
  625.     union {
  626.     D3DCOLORVALUE   specular;       /* Specular 'shininess' */
  627.     D3DCOLORVALUE   dcvSpecular;
  628.     };
  629.     union {
  630.     D3DCOLORVALUE   emissive;       /* Emissive color RGB */
  631.     D3DCOLORVALUE   dcvEmissive;
  632.     };
  633.     union {
  634.     D3DVALUE        power;          /* Sharpness if specular highlight */
  635.     D3DVALUE        dvPower;
  636.     };
  637. } D3DMATERIAL7, *LPD3DMATERIAL7;
  638.  
  639. typedef enum _D3DLIGHTTYPE {
  640.     D3DLIGHT_POINT          = 1,
  641.     D3DLIGHT_SPOT           = 2,
  642.     D3DLIGHT_DIRECTIONAL    = 3,
  643. // Note: The following light type (D3DLIGHT_PARALLELPOINT)
  644. // is no longer supported from D3D for DX7 onwards.
  645.     D3DLIGHT_PARALLELPOINT  = 4,
  646.     D3DLIGHT_GLSPOT         = 5,
  647.     D3DLIGHT_FORCE_DWORD    = 0x7fffffff, /* force 32-bit size enum */
  648. } D3DLIGHTTYPE;
  649.  
  650. /*
  651.  * Structure defining a light source and its properties.
  652.  */
  653. typedef struct _D3DLIGHT {
  654.     DWORD           dwSize;
  655.     D3DLIGHTTYPE    dltType;            /* Type of light source */
  656.     D3DCOLORVALUE   dcvColor;           /* Color of light */
  657.     D3DVECTOR       dvPosition;         /* Position in world space */
  658.     D3DVECTOR       dvDirection;        /* Direction in world space */
  659.     D3DVALUE        dvRange;            /* Cutoff range */
  660.     D3DVALUE        dvFalloff;          /* Falloff */
  661.     D3DVALUE        dvAttenuation0;     /* Constant attenuation */
  662.     D3DVALUE        dvAttenuation1;     /* Linear attenuation */
  663.     D3DVALUE        dvAttenuation2;     /* Quadratic attenuation */
  664.     D3DVALUE        dvTheta;            /* Inner angle of spotlight cone */
  665.     D3DVALUE        dvPhi;              /* Outer angle of spotlight cone */
  666. } D3DLIGHT, *LPD3DLIGHT;
  667.  
  668. typedef struct _D3DLIGHT7 {
  669.     D3DLIGHTTYPE    dltType;            /* Type of light source */
  670.     D3DCOLORVALUE   dcvDiffuse;         /* Diffuse color of light */
  671.     D3DCOLORVALUE   dcvSpecular;        /* Specular color of light */
  672.     D3DCOLORVALUE   dcvAmbient;         /* Ambient color of light */
  673.     D3DVECTOR       dvPosition;         /* Position in world space */
  674.     D3DVECTOR       dvDirection;        /* Direction in world space */
  675.     D3DVALUE        dvRange;            /* Cutoff range */
  676.     D3DVALUE        dvFalloff;          /* Falloff */
  677.     D3DVALUE        dvAttenuation0;     /* Constant attenuation */
  678.     D3DVALUE        dvAttenuation1;     /* Linear attenuation */
  679.     D3DVALUE        dvAttenuation2;     /* Quadratic attenuation */
  680.     D3DVALUE        dvTheta;            /* Inner angle of spotlight cone */
  681.     D3DVALUE        dvPhi;              /* Outer angle of spotlight cone */
  682. } D3DLIGHT7, *LPD3DLIGHT7;
  683.  
  684. /*
  685.  * Structure defining a light source and its properties.
  686.  */
  687.  
  688. /* flags bits */
  689. #define D3DLIGHT_ACTIVE         0x00000001
  690. #define D3DLIGHT_NO_SPECULAR    0x00000002
  691. #define D3DLIGHT_ALL (D3DLIGHT_ACTIVE | D3DLIGHT_NO_SPECULAR)
  692.  
  693. /* maximum valid light range */
  694. #define D3DLIGHT_RANGE_MAX      ((float)sqrt(FLT_MAX))
  695.  
  696. typedef struct _D3DLIGHT2 {
  697.     DWORD           dwSize;
  698.     D3DLIGHTTYPE    dltType;        /* Type of light source */
  699.     D3DCOLORVALUE   dcvColor;       /* Color of light */
  700.     D3DVECTOR       dvPosition;     /* Position in world space */
  701.     D3DVECTOR       dvDirection;    /* Direction in world space */
  702.     D3DVALUE        dvRange;        /* Cutoff range */
  703.     D3DVALUE        dvFalloff;      /* Falloff */
  704.     D3DVALUE        dvAttenuation0; /* Constant attenuation */
  705.     D3DVALUE        dvAttenuation1; /* Linear attenuation */
  706.     D3DVALUE        dvAttenuation2; /* Quadratic attenuation */
  707.     D3DVALUE        dvTheta;        /* Inner angle of spotlight cone */
  708.     D3DVALUE        dvPhi;          /* Outer angle of spotlight cone */
  709.     DWORD           dwFlags;
  710. } D3DLIGHT2, *LPD3DLIGHT2;
  711.  
  712. typedef struct _D3DLIGHTDATA {
  713.     DWORD                dwSize;
  714.     LPD3DLIGHTINGELEMENT lpIn;      /* Input positions and normals */
  715.     DWORD                dwInSize;  /* Stride of input elements */
  716.     LPD3DTLVERTEX        lpOut;     /* Output colors */
  717.     DWORD                dwOutSize; /* Stride of output colors */
  718. } D3DLIGHTDATA, *LPD3DLIGHTDATA;
  719.  
  720. /*
  721.  * Before DX5, these values were in an enum called
  722.  * D3DCOLORMODEL. This was not correct, since they are
  723.  * bit flags. A driver can surface either or both flags
  724.  * in the dcmColorModel member of D3DDEVICEDESC.
  725.  */
  726. #define D3DCOLOR_MONO   1
  727. #define D3DCOLOR_RGB    2
  728.  
  729. typedef DWORD D3DCOLORMODEL;
  730.  
  731. /*
  732.  * Options for clearing
  733.  */
  734. #define D3DCLEAR_TARGET            0x00000001l  /* Clear target surface */
  735. #define D3DCLEAR_ZBUFFER           0x00000002l  /* Clear target z buffer */
  736. #define D3DCLEAR_STENCIL           0x00000004l  /* Clear stencil planes */
  737.  
  738. /*
  739.  * Execute buffers are allocated via Direct3D.  These buffers may then
  740.  * be filled by the application with instructions to execute along with
  741.  * vertex data.
  742.  */
  743.  
  744. /*
  745.  * Supported op codes for execute instructions.
  746.  */
  747. typedef enum _D3DOPCODE {
  748.     D3DOP_POINT                 = 1,
  749.     D3DOP_LINE                  = 2,
  750.     D3DOP_TRIANGLE      = 3,
  751.     D3DOP_MATRIXLOAD        = 4,
  752.     D3DOP_MATRIXMULTIPLY    = 5,
  753.     D3DOP_STATETRANSFORM        = 6,
  754.     D3DOP_STATELIGHT        = 7,
  755.     D3DOP_STATERENDER       = 8,
  756.     D3DOP_PROCESSVERTICES       = 9,
  757.     D3DOP_TEXTURELOAD       = 10,
  758.     D3DOP_EXIT                  = 11,
  759.     D3DOP_BRANCHFORWARD     = 12,
  760.     D3DOP_SPAN          = 13,
  761.     D3DOP_SETSTATUS     = 14,
  762.     D3DOP_FORCE_DWORD           = 0x7fffffff, /* force 32-bit size enum */
  763. } D3DOPCODE;
  764.  
  765. typedef struct _D3DINSTRUCTION {
  766.     BYTE bOpcode;   /* Instruction opcode */
  767.     BYTE bSize;     /* Size of each instruction data unit */
  768.     WORD wCount;    /* Count of instruction data units to follow */
  769. } D3DINSTRUCTION, *LPD3DINSTRUCTION;
  770.  
  771. /*
  772.  * Structure for texture loads
  773.  */
  774. typedef struct _D3DTEXTURELOAD {
  775.     D3DTEXTUREHANDLE hDestTexture;
  776.     D3DTEXTUREHANDLE hSrcTexture;
  777. } D3DTEXTURELOAD, *LPD3DTEXTURELOAD;
  778.  
  779. /*
  780.  * Structure for picking
  781.  */
  782. typedef struct _D3DPICKRECORD {
  783.     BYTE     bOpcode;
  784.     BYTE     bPad;
  785.     DWORD    dwOffset;
  786.     D3DVALUE dvZ;
  787. } D3DPICKRECORD, *LPD3DPICKRECORD;
  788.  
  789. /*
  790.  * The following defines the rendering states which can be set in the
  791.  * execute buffer.
  792.  */
  793.  
  794. typedef enum _D3DSHADEMODE {
  795.     D3DSHADE_FLAT              = 1,
  796.     D3DSHADE_GOURAUD           = 2,
  797.     D3DSHADE_PHONG             = 3,
  798.     D3DSHADE_FORCE_DWORD       = 0x7fffffff, /* force 32-bit size enum */
  799. } D3DSHADEMODE;
  800.  
  801. typedef enum _D3DFILLMODE {
  802.     D3DFILL_POINT          = 1,
  803.     D3DFILL_WIREFRAME          = 2,
  804.     D3DFILL_SOLID          = 3,
  805.     D3DFILL_FORCE_DWORD        = 0x7fffffff, /* force 32-bit size enum */
  806. } D3DFILLMODE;
  807.  
  808. typedef struct _D3DLINEPATTERN {
  809.     WORD    wRepeatFactor;
  810.     WORD    wLinePattern;
  811. } D3DLINEPATTERN;
  812.  
  813. typedef enum _D3DTEXTUREFILTER {
  814.     D3DFILTER_NEAREST          = 1,
  815.     D3DFILTER_LINEAR           = 2,
  816.     D3DFILTER_MIPNEAREST       = 3,
  817.     D3DFILTER_MIPLINEAR        = 4,
  818.     D3DFILTER_LINEARMIPNEAREST = 5,
  819.     D3DFILTER_LINEARMIPLINEAR  = 6,
  820.     D3DFILTER_FORCE_DWORD      = 0x7fffffff, /* force 32-bit size enum */
  821. } D3DTEXTUREFILTER;
  822.  
  823. typedef enum _D3DBLEND {
  824.     D3DBLEND_ZERO              = 1,
  825.     D3DBLEND_ONE               = 2,
  826.     D3DBLEND_SRCCOLOR          = 3,
  827.     D3DBLEND_INVSRCCOLOR       = 4,
  828.     D3DBLEND_SRCALPHA          = 5,
  829.     D3DBLEND_INVSRCALPHA       = 6,
  830.     D3DBLEND_DESTALPHA         = 7,
  831.     D3DBLEND_INVDESTALPHA      = 8,
  832.     D3DBLEND_DESTCOLOR         = 9,
  833.     D3DBLEND_INVDESTCOLOR      = 10,
  834.     D3DBLEND_SRCALPHASAT       = 11,
  835.     D3DBLEND_BOTHSRCALPHA      = 12,
  836.     D3DBLEND_BOTHINVSRCALPHA   = 13,
  837.     D3DBLEND_FORCE_DWORD       = 0x7fffffff, /* force 32-bit size enum */
  838. } D3DBLEND;
  839.  
  840. typedef enum _D3DTEXTUREBLEND {
  841.     D3DTBLEND_DECAL            = 1,
  842.     D3DTBLEND_MODULATE         = 2,
  843.     D3DTBLEND_DECALALPHA       = 3,
  844.     D3DTBLEND_MODULATEALPHA    = 4,
  845.     D3DTBLEND_DECALMASK        = 5,
  846.     D3DTBLEND_MODULATEMASK     = 6,
  847.     D3DTBLEND_COPY             = 7,
  848.     D3DTBLEND_ADD              = 8,
  849.     D3DTBLEND_FORCE_DWORD      = 0x7fffffff, /* force 32-bit size enum */
  850. } D3DTEXTUREBLEND;
  851.  
  852. typedef enum _D3DTEXTUREADDRESS {
  853.     D3DTADDRESS_WRAP           = 1,
  854.     D3DTADDRESS_MIRROR         = 2,
  855.     D3DTADDRESS_CLAMP          = 3,
  856.     D3DTADDRESS_BORDER         = 4,
  857.     D3DTADDRESS_FORCE_DWORD    = 0x7fffffff, /* force 32-bit size enum */
  858. } D3DTEXTUREADDRESS;
  859.  
  860. typedef enum _D3DCULL {
  861.     D3DCULL_NONE               = 1,
  862.     D3DCULL_CW                 = 2,
  863.     D3DCULL_CCW                = 3,
  864.     D3DCULL_FORCE_DWORD        = 0x7fffffff, /* force 32-bit size enum */
  865. } D3DCULL;
  866.  
  867. typedef enum _D3DCMPFUNC {
  868.     D3DCMP_NEVER               = 1,
  869.     D3DCMP_LESS                = 2,
  870.     D3DCMP_EQUAL               = 3,
  871.     D3DCMP_LESSEQUAL           = 4,
  872.     D3DCMP_GREATER             = 5,
  873.     D3DCMP_NOTEQUAL            = 6,
  874.     D3DCMP_GREATEREQUAL        = 7,
  875.     D3DCMP_ALWAYS              = 8,
  876.     D3DCMP_FORCE_DWORD         = 0x7fffffff, /* force 32-bit size enum */
  877. } D3DCMPFUNC;
  878.  
  879. typedef enum _D3DSTENCILOP {
  880.     D3DSTENCILOP_KEEP           = 1,
  881.     D3DSTENCILOP_ZERO           = 2,
  882.     D3DSTENCILOP_REPLACE        = 3,
  883.     D3DSTENCILOP_INCRSAT        = 4,
  884.     D3DSTENCILOP_DECRSAT        = 5,
  885.     D3DSTENCILOP_INVERT         = 6,
  886.     D3DSTENCILOP_INCR           = 7,
  887.     D3DSTENCILOP_DECR           = 8,
  888.     D3DSTENCILOP_FORCE_DWORD    = 0x7fffffff, /* force 32-bit size enum */
  889. } D3DSTENCILOP;
  890.  
  891. typedef enum _D3DFOGMODE {
  892.     D3DFOG_NONE                = 0,
  893.     D3DFOG_EXP                 = 1,
  894.     D3DFOG_EXP2                = 2,
  895.     D3DFOG_LINEAR              = 3,
  896.     D3DFOG_FORCE_DWORD         = 0x7fffffff, /* force 32-bit size enum */
  897. } D3DFOGMODE;
  898.  
  899. typedef enum _D3DZBUFFERTYPE {
  900.     D3DZB_FALSE                 = 0,
  901.     D3DZB_TRUE                  = 1, // Z buffering
  902.     D3DZB_USEW                  = 2, // W buffering
  903.     D3DZB_FORCE_DWORD           = 0x7fffffff, /* force 32-bit size enum */
  904. } D3DZBUFFERTYPE;
  905.  
  906. typedef enum _D3DANTIALIASMODE {
  907.     D3DANTIALIAS_NONE          = 0,
  908.     D3DANTIALIAS_SORTDEPENDENT = 1,
  909.     D3DANTIALIAS_SORTINDEPENDENT = 2,
  910.     D3DANTIALIAS_FORCE_DWORD   = 0x7fffffff, /* force 32-bit size enum */
  911. } D3DANTIALIASMODE;
  912.  
  913. // Vertex types supported by Direct3D
  914. typedef enum _D3DVERTEXTYPE {
  915.     D3DVT_VERTEX        = 1,
  916.     D3DVT_LVERTEX       = 2,
  917.     D3DVT_TLVERTEX      = 3,
  918.     D3DVT_FORCE_DWORD   = 0x7fffffff, /* force 32-bit size enum */
  919. } D3DVERTEXTYPE;
  920.  
  921. // Primitives supported by draw-primitive API
  922. typedef enum _D3DPRIMITIVETYPE {
  923.     D3DPT_POINTLIST     = 1,
  924.     D3DPT_LINELIST      = 2,
  925.     D3DPT_LINESTRIP     = 3,
  926.     D3DPT_TRIANGLELIST  = 4,
  927.     D3DPT_TRIANGLESTRIP = 5,
  928.     D3DPT_TRIANGLEFAN   = 6,
  929.     D3DPT_FORCE_DWORD   = 0x7fffffff, /* force 32-bit size enum */
  930. } D3DPRIMITIVETYPE;
  931.  
  932. /*
  933.  * Amount to add to a state to generate the override for that state.
  934.  */
  935. #define D3DSTATE_OVERRIDE_BIAS      256
  936.  
  937. /*
  938.  * A state which sets the override flag for the specified state type.
  939.  */
  940. #define D3DSTATE_OVERRIDE(type) (D3DRENDERSTATETYPE)(((DWORD) (type) + D3DSTATE_OVERRIDE_BIAS))
  941.  
  942. typedef enum _D3DTRANSFORMSTATETYPE {
  943.     D3DTRANSFORMSTATE_WORLD         = 1,
  944.     D3DTRANSFORMSTATE_VIEW          = 2,
  945.     D3DTRANSFORMSTATE_PROJECTION    = 3,
  946.     D3DTRANSFORMSTATE_WORLD1        = 4,  // 2nd matrix to blend
  947.     D3DTRANSFORMSTATE_WORLD2        = 5,  // 3rd matrix to blend
  948.     D3DTRANSFORMSTATE_WORLD3        = 6,  // 4th matrix to blend
  949.     D3DTRANSFORMSTATE_TEXTURE0      = 16,
  950.     D3DTRANSFORMSTATE_TEXTURE1      = 17,
  951.     D3DTRANSFORMSTATE_TEXTURE2      = 18,
  952.     D3DTRANSFORMSTATE_TEXTURE3      = 19,
  953.     D3DTRANSFORMSTATE_TEXTURE4      = 20,
  954.     D3DTRANSFORMSTATE_TEXTURE5      = 21,
  955.     D3DTRANSFORMSTATE_TEXTURE6      = 22,
  956.     D3DTRANSFORMSTATE_TEXTURE7      = 23,
  957.     D3DTRANSFORMSTATE_FORCE_DWORD     = 0x7fffffff, /* force 32-bit size enum */
  958. } D3DTRANSFORMSTATETYPE;
  959.  
  960. typedef enum _D3DLIGHTSTATETYPE {
  961.     D3DLIGHTSTATE_MATERIAL          = 1,
  962.     D3DLIGHTSTATE_AMBIENT           = 2,
  963.     D3DLIGHTSTATE_COLORMODEL        = 3,
  964.     D3DLIGHTSTATE_FOGMODE           = 4,
  965.     D3DLIGHTSTATE_FOGSTART          = 5,
  966.     D3DLIGHTSTATE_FOGEND            = 6,
  967.     D3DLIGHTSTATE_FOGDENSITY        = 7,
  968.     D3DLIGHTSTATE_COLORVERTEX       = 8,
  969.     D3DLIGHTSTATE_FORCE_DWORD         = 0x7fffffff, /* force 32-bit size enum */
  970. } D3DLIGHTSTATETYPE;
  971.  
  972. typedef enum _D3DRENDERSTATETYPE {
  973.     D3DRENDERSTATE_ANTIALIAS          = 2,    /* D3DANTIALIASMODE */
  974.     D3DRENDERSTATE_TEXTUREPERSPECTIVE = 4,    /* TRUE for perspective correction */
  975.     D3DRENDERSTATE_ZENABLE            = 7,    /* D3DZBUFFERTYPE (or TRUE/FALSE for legacy) */
  976.     D3DRENDERSTATE_FILLMODE           = 8,    /* D3DFILL_MODE        */
  977.     D3DRENDERSTATE_SHADEMODE          = 9,    /* D3DSHADEMODE */
  978.     D3DRENDERSTATE_LINEPATTERN        = 10,   /* D3DLINEPATTERN */
  979.     D3DRENDERSTATE_ZWRITEENABLE       = 14,   /* TRUE to enable z writes */
  980.     D3DRENDERSTATE_ALPHATESTENABLE    = 15,   /* TRUE to enable alpha tests */
  981.     D3DRENDERSTATE_LASTPIXEL          = 16,   /* TRUE for last-pixel on lines */
  982.     D3DRENDERSTATE_SRCBLEND           = 19,   /* D3DBLEND */
  983.     D3DRENDERSTATE_DESTBLEND          = 20,   /* D3DBLEND */
  984.     D3DRENDERSTATE_CULLMODE           = 22,   /* D3DCULL */
  985.     D3DRENDERSTATE_ZFUNC              = 23,   /* D3DCMPFUNC */
  986.     D3DRENDERSTATE_ALPHAREF           = 24,   /* D3DFIXED */
  987.     D3DRENDERSTATE_ALPHAFUNC          = 25,   /* D3DCMPFUNC */
  988.     D3DRENDERSTATE_DITHERENABLE       = 26,   /* TRUE to enable dithering */
  989.     D3DRENDERSTATE_ALPHABLENDENABLE   = 27,   /* TRUE to enable alpha blending */
  990.     D3DRENDERSTATE_FOGENABLE          = 28,   /* TRUE to enable fog blending */
  991.     D3DRENDERSTATE_SPECULARENABLE     = 29,   /* TRUE to enable specular */
  992.     D3DRENDERSTATE_ZVISIBLE           = 30,   /* TRUE to enable z checking */
  993.     D3DRENDERSTATE_STIPPLEDALPHA      = 33,   /* TRUE to enable stippled alpha (RGB device only) */
  994.     D3DRENDERSTATE_FOGCOLOR           = 34,   /* D3DCOLOR */
  995.     D3DRENDERSTATE_FOGTABLEMODE       = 35,   /* D3DFOGMODE */
  996.     D3DRENDERSTATE_FOGSTART           = 36,   /* Fog start (for both vertex and pixel fog) */
  997.     D3DRENDERSTATE_FOGEND             = 37,   /* Fog end      */
  998.     D3DRENDERSTATE_FOGDENSITY         = 38,   /* Fog density  */
  999.     D3DRENDERSTATE_EDGEANTIALIAS      = 40,   /* TRUE to enable edge antialiasing */
  1000.     D3DRENDERSTATE_COLORKEYENABLE     = 41,   /* TRUE to enable source colorkeyed textures */
  1001.     D3DRENDERSTATE_ZBIAS              = 47,   /* LONG Z bias */
  1002.     D3DRENDERSTATE_RANGEFOGENABLE     = 48,   /* Enables range-based fog */
  1003.     D3DRENDERSTATE_STENCILENABLE      = 52,   /* BOOL enable/disable stenciling */
  1004.     D3DRENDERSTATE_STENCILFAIL        = 53,   /* D3DSTENCILOP to do if stencil test fails */
  1005.     D3DRENDERSTATE_STENCILZFAIL       = 54,   /* D3DSTENCILOP to do if stencil test passes and Z test fails */
  1006.     D3DRENDERSTATE_STENCILPASS        = 55,   /* D3DSTENCILOP to do if both stencil and Z tests pass */
  1007.     D3DRENDERSTATE_STENCILFUNC        = 56,   /* D3DCMPFUNC fn.  Stencil Test passes if ((ref & mask) stencilfn (stencil & mask)) is true */
  1008.     D3DRENDERSTATE_STENCILREF         = 57,   /* Reference value used in stencil test */
  1009.     D3DRENDERSTATE_STENCILMASK        = 58,   /* Mask value used in stencil test */
  1010.     D3DRENDERSTATE_STENCILWRITEMASK   = 59,   /* Write mask applied to values written to stencil buffer */
  1011.     D3DRENDERSTATE_TEXTUREFACTOR      = 60,   /* D3DCOLOR used for multi-texture blend */
  1012.  
  1013.     /*
  1014.      * 128 values [128, 255] are reserved for texture coordinate wrap flags.
  1015.      * These are constructed with the D3DWRAP_U and D3DWRAP_V macros. Using
  1016.      * a flags word preserves forward compatibility with texture coordinates
  1017.      * that are >2D.
  1018.      */
  1019.     D3DRENDERSTATE_WRAP0              = 128,  /* wrap for 1st texture coord. set */
  1020.     D3DRENDERSTATE_WRAP1              = 129,  /* wrap for 2nd texture coord. set */
  1021.     D3DRENDERSTATE_WRAP2              = 130,  /* wrap for 3rd texture coord. set */
  1022.     D3DRENDERSTATE_WRAP3              = 131,  /* wrap for 4th texture coord. set */
  1023.     D3DRENDERSTATE_WRAP4              = 132,  /* wrap for 5th texture coord. set */
  1024.     D3DRENDERSTATE_WRAP5              = 133,  /* wrap for 6th texture coord. set */
  1025.     D3DRENDERSTATE_WRAP6              = 134,  /* wrap for 7th texture coord. set */
  1026.     D3DRENDERSTATE_WRAP7              = 135,  /* wrap for 8th texture coord. set */
  1027.     D3DRENDERSTATE_CLIPPING            = 136,
  1028.     D3DRENDERSTATE_LIGHTING            = 137,
  1029.     D3DRENDERSTATE_EXTENTS             = 138,
  1030.     D3DRENDERSTATE_AMBIENT             = 139,
  1031.     D3DRENDERSTATE_FOGVERTEXMODE       = 140,
  1032.     D3DRENDERSTATE_COLORVERTEX         = 141,
  1033.     D3DRENDERSTATE_LOCALVIEWER         = 142,
  1034.     D3DRENDERSTATE_NORMALIZENORMALS    = 143,
  1035.     D3DRENDERSTATE_COLORKEYBLENDENABLE = 144,
  1036.     D3DRENDERSTATE_DIFFUSEMATERIALSOURCE    = 145,
  1037.     D3DRENDERSTATE_SPECULARMATERIALSOURCE   = 146,
  1038.     D3DRENDERSTATE_AMBIENTMATERIALSOURCE    = 147,
  1039.     D3DRENDERSTATE_EMISSIVEMATERIALSOURCE   = 148,
  1040.     D3DRENDERSTATE_VERTEXBLEND              = 151,
  1041.     D3DRENDERSTATE_CLIPPLANEENABLE          = 152,
  1042.  
  1043. //
  1044. // retired renderstates - not supported for DX7 interfaces
  1045. //
  1046.     D3DRENDERSTATE_TEXTUREHANDLE      = 1,    /* Texture handle for legacy interfaces (Texture,Texture2) */
  1047.     D3DRENDERSTATE_TEXTUREADDRESS     = 3,    /* D3DTEXTUREADDRESS  */
  1048.     D3DRENDERSTATE_WRAPU              = 5,    /* TRUE for wrapping in u */
  1049.     D3DRENDERSTATE_WRAPV              = 6,    /* TRUE for wrapping in v */
  1050.     D3DRENDERSTATE_MONOENABLE         = 11,   /* TRUE to enable mono rasterization */
  1051.     D3DRENDERSTATE_ROP2               = 12,   /* ROP2 */
  1052.     D3DRENDERSTATE_PLANEMASK          = 13,   /* DWORD physical plane mask */
  1053.     D3DRENDERSTATE_TEXTUREMAG         = 17,   /* D3DTEXTUREFILTER */
  1054.     D3DRENDERSTATE_TEXTUREMIN         = 18,   /* D3DTEXTUREFILTER */
  1055.     D3DRENDERSTATE_TEXTUREMAPBLEND    = 21,   /* D3DTEXTUREBLEND */
  1056.     D3DRENDERSTATE_SUBPIXEL           = 31,   /* TRUE to enable subpixel correction */
  1057.     D3DRENDERSTATE_SUBPIXELX          = 32,   /* TRUE to enable correction in X only */
  1058.     D3DRENDERSTATE_STIPPLEENABLE      = 39,   /* TRUE to enable stippling */
  1059.     D3DRENDERSTATE_BORDERCOLOR        = 43,   /* Border color for texturing w/border */
  1060.     D3DRENDERSTATE_TEXTUREADDRESSU    = 44,   /* Texture addressing mode for U coordinate */
  1061.     D3DRENDERSTATE_TEXTUREADDRESSV    = 45,   /* Texture addressing mode for V coordinate */
  1062.     D3DRENDERSTATE_MIPMAPLODBIAS      = 46,   /* D3DVALUE Mipmap LOD bias */
  1063.     D3DRENDERSTATE_ANISOTROPY         = 49,   /* Max. anisotropy. 1 = no anisotropy */
  1064.     D3DRENDERSTATE_FLUSHBATCH         = 50,   /* Explicit flush for DP batching (DX5 Only) */
  1065.     D3DRENDERSTATE_TRANSLUCENTSORTINDEPENDENT=51, /* BOOL enable sort-independent transparency */
  1066.     D3DRENDERSTATE_STIPPLEPATTERN00   = 64,   /* Stipple pattern 01...  */
  1067.     D3DRENDERSTATE_STIPPLEPATTERN01   = 65,
  1068.     D3DRENDERSTATE_STIPPLEPATTERN02   = 66,
  1069.     D3DRENDERSTATE_STIPPLEPATTERN03   = 67,
  1070.     D3DRENDERSTATE_STIPPLEPATTERN04   = 68,
  1071.     D3DRENDERSTATE_STIPPLEPATTERN05   = 69,
  1072.     D3DRENDERSTATE_STIPPLEPATTERN06   = 70,
  1073.     D3DRENDERSTATE_STIPPLEPATTERN07   = 71,
  1074.     D3DRENDERSTATE_STIPPLEPATTERN08   = 72,
  1075.     D3DRENDERSTATE_STIPPLEPATTERN09   = 73,
  1076.     D3DRENDERSTATE_STIPPLEPATTERN10   = 74,
  1077.     D3DRENDERSTATE_STIPPLEPATTERN11   = 75,
  1078.     D3DRENDERSTATE_STIPPLEPATTERN12   = 76,
  1079.     D3DRENDERSTATE_STIPPLEPATTERN13   = 77,
  1080.     D3DRENDERSTATE_STIPPLEPATTERN14   = 78,
  1081.     D3DRENDERSTATE_STIPPLEPATTERN15   = 79,
  1082.     D3DRENDERSTATE_STIPPLEPATTERN16   = 80,
  1083.     D3DRENDERSTATE_STIPPLEPATTERN17   = 81,
  1084.     D3DRENDERSTATE_STIPPLEPATTERN18   = 82,
  1085.     D3DRENDERSTATE_STIPPLEPATTERN19   = 83,
  1086.     D3DRENDERSTATE_STIPPLEPATTERN20   = 84,
  1087.     D3DRENDERSTATE_STIPPLEPATTERN21   = 85,
  1088.     D3DRENDERSTATE_STIPPLEPATTERN22   = 86,
  1089.     D3DRENDERSTATE_STIPPLEPATTERN23   = 87,
  1090.     D3DRENDERSTATE_STIPPLEPATTERN24   = 88,
  1091.     D3DRENDERSTATE_STIPPLEPATTERN25   = 89,
  1092.     D3DRENDERSTATE_STIPPLEPATTERN26   = 90,
  1093.     D3DRENDERSTATE_STIPPLEPATTERN27   = 91,
  1094.     D3DRENDERSTATE_STIPPLEPATTERN28   = 92,
  1095.     D3DRENDERSTATE_STIPPLEPATTERN29   = 93,
  1096.     D3DRENDERSTATE_STIPPLEPATTERN30   = 94,
  1097.     D3DRENDERSTATE_STIPPLEPATTERN31   = 95,
  1098.  
  1099. //
  1100. // retired renderstate names - the values are still used under new naming conventions
  1101. //
  1102.     D3DRENDERSTATE_FOGTABLESTART      = 36,   /* Fog table start    */
  1103.     D3DRENDERSTATE_FOGTABLEEND        = 37,   /* Fog table end      */
  1104.     D3DRENDERSTATE_FOGTABLEDENSITY    = 38,   /* Fog table density  */
  1105.  
  1106.     D3DRENDERSTATE_FORCE_DWORD        = 0x7fffffff, /* force 32-bit size enum */
  1107. } D3DRENDERSTATETYPE;
  1108.  
  1109. // Values for material source
  1110. typedef enum _D3DMATERIALCOLORSOURCE
  1111. {
  1112.     D3DMCS_MATERIAL = 0,                // Color from material is used
  1113.     D3DMCS_COLOR1   = 1,                // Diffuse vertex color is used
  1114.     D3DMCS_COLOR2   = 2,                // Specular vertex color is used
  1115.     D3DMCS_FORCE_DWORD = 0x7fffffff,    // force 32-bit size enum
  1116. } D3DMATERIALCOLORSOURCE;
  1117.  
  1118.  
  1119. // For back-compatibility with legacy compilations
  1120. #define D3DRENDERSTATE_BLENDENABLE      D3DRENDERSTATE_ALPHABLENDENABLE
  1121.  
  1122.  
  1123. // Bias to apply to the texture coordinate set to apply a wrap to.
  1124. #define D3DRENDERSTATE_WRAPBIAS                 128UL
  1125.  
  1126. /* Flags to construct the WRAP render states */
  1127. #define D3DWRAP_U   0x00000001L
  1128. #define D3DWRAP_V   0x00000002L
  1129.  
  1130.  
  1131. /* Flags to construct the WRAP render states for 1D thru 4D texture coordinates */
  1132. #define D3DWRAPCOORD_0   0x00000001L    // same as D3DWRAP_U
  1133. #define D3DWRAPCOORD_1   0x00000002L    // same as D3DWRAP_V
  1134. #define D3DWRAPCOORD_2   0x00000004L
  1135. #define D3DWRAPCOORD_3   0x00000008L
  1136.  
  1137.  
  1138. #define D3DRENDERSTATE_STIPPLEPATTERN(y) (D3DRENDERSTATE_STIPPLEPATTERN00 + (y))
  1139.  
  1140. typedef struct _D3DSTATE {
  1141.     union {
  1142.     D3DTRANSFORMSTATETYPE   dtstTransformStateType;
  1143.     D3DLIGHTSTATETYPE   dlstLightStateType;
  1144.     D3DRENDERSTATETYPE  drstRenderStateType;
  1145.     };
  1146.     union {
  1147.     DWORD           dwArg[1];
  1148.     D3DVALUE        dvArg[1];
  1149.     };
  1150. } D3DSTATE, *LPD3DSTATE;
  1151.  
  1152. /*
  1153.  * Operation used to load matrices
  1154.  * hDstMat = hSrcMat
  1155.  */
  1156. typedef struct _D3DMATRIXLOAD {
  1157.     D3DMATRIXHANDLE hDestMatrix;   /* Destination matrix */
  1158.     D3DMATRIXHANDLE hSrcMatrix;   /* Source matrix */
  1159. } D3DMATRIXLOAD, *LPD3DMATRIXLOAD;
  1160.  
  1161. /*
  1162.  * Operation used to multiply matrices
  1163.  * hDstMat = hSrcMat1 * hSrcMat2
  1164.  */
  1165. typedef struct _D3DMATRIXMULTIPLY {
  1166.     D3DMATRIXHANDLE hDestMatrix;   /* Destination matrix */
  1167.     D3DMATRIXHANDLE hSrcMatrix1;  /* First source matrix */
  1168.     D3DMATRIXHANDLE hSrcMatrix2;  /* Second source matrix */
  1169. } D3DMATRIXMULTIPLY, *LPD3DMATRIXMULTIPLY;
  1170.  
  1171. /*
  1172.  * Operation used to transform and light vertices.
  1173.  */
  1174. typedef struct _D3DPROCESSVERTICES {
  1175.     DWORD        dwFlags;    /* Do we transform or light or just copy? */
  1176.     WORD         wStart;     /* Index to first vertex in source */
  1177.     WORD         wDest;      /* Index to first vertex in local buffer */
  1178.     DWORD        dwCount;    /* Number of vertices to be processed */
  1179.     DWORD    dwReserved; /* Must be zero */
  1180. } D3DPROCESSVERTICES, *LPD3DPROCESSVERTICES;
  1181.  
  1182. #define D3DPROCESSVERTICES_TRANSFORMLIGHT   0x00000000L
  1183. #define D3DPROCESSVERTICES_TRANSFORM        0x00000001L
  1184. #define D3DPROCESSVERTICES_COPY         0x00000002L
  1185. #define D3DPROCESSVERTICES_OPMASK       0x00000007L
  1186.  
  1187. #define D3DPROCESSVERTICES_UPDATEEXTENTS    0x00000008L
  1188. #define D3DPROCESSVERTICES_NOCOLOR      0x00000010L
  1189.  
  1190.  
  1191. /*
  1192.  * State enumerants for per-stage texture processing.
  1193.  */
  1194. typedef enum _D3DTEXTURESTAGESTATETYPE
  1195. {
  1196.     D3DTSS_COLOROP        =  1, /* D3DTEXTUREOP - per-stage blending controls for color channels */
  1197.     D3DTSS_COLORARG1      =  2, /* D3DTA_* (texture arg) */
  1198.     D3DTSS_COLORARG2      =  3, /* D3DTA_* (texture arg) */
  1199.     D3DTSS_ALPHAOP        =  4, /* D3DTEXTUREOP - per-stage blending controls for alpha channel */
  1200.     D3DTSS_ALPHAARG1      =  5, /* D3DTA_* (texture arg) */
  1201.     D3DTSS_ALPHAARG2      =  6, /* D3DTA_* (texture arg) */
  1202.     D3DTSS_BUMPENVMAT00   =  7, /* D3DVALUE (bump mapping matrix) */
  1203.     D3DTSS_BUMPENVMAT01   =  8, /* D3DVALUE (bump mapping matrix) */
  1204.     D3DTSS_BUMPENVMAT10   =  9, /* D3DVALUE (bump mapping matrix) */
  1205.     D3DTSS_BUMPENVMAT11   = 10, /* D3DVALUE (bump mapping matrix) */
  1206.     D3DTSS_TEXCOORDINDEX  = 11, /* identifies which set of texture coordinates index this texture */
  1207.     D3DTSS_ADDRESS        = 12, /* D3DTEXTUREADDRESS for both coordinates */
  1208.     D3DTSS_ADDRESSU       = 13, /* D3DTEXTUREADDRESS for U coordinate */
  1209.     D3DTSS_ADDRESSV       = 14, /* D3DTEXTUREADDRESS for V coordinate */
  1210.     D3DTSS_BORDERCOLOR    = 15, /* D3DCOLOR */
  1211.     D3DTSS_MAGFILTER      = 16, /* D3DTEXTUREMAGFILTER filter to use for magnification */
  1212.     D3DTSS_MINFILTER      = 17, /* D3DTEXTUREMINFILTER filter to use for minification */
  1213.     D3DTSS_MIPFILTER      = 18, /* D3DTEXTUREMIPFILTER filter to use between mipmaps during minification */
  1214.     D3DTSS_MIPMAPLODBIAS  = 19, /* D3DVALUE Mipmap LOD bias */
  1215.     D3DTSS_MAXMIPLEVEL    = 20, /* DWORD 0..(n-1) LOD index of largest map to use (0 == largest) */
  1216.     D3DTSS_MAXANISOTROPY  = 21, /* DWORD maximum anisotropy */
  1217.     D3DTSS_BUMPENVLSCALE  = 22, /* D3DVALUE scale for bump map luminance */
  1218.     D3DTSS_BUMPENVLOFFSET = 23, /* D3DVALUE offset for bump map luminance */
  1219.     D3DTSS_TEXTURETRANSFORMFLAGS = 24, /* D3DTEXTURETRANSFORMFLAGS controls texture transform */
  1220.     D3DTSS_FORCE_DWORD   = 0x7fffffff, /* force 32-bit size enum */
  1221. } D3DTEXTURESTAGESTATETYPE;
  1222.  
  1223. // Values, used with D3DTSS_TEXCOORDINDEX, to specify that the vertex data(position
  1224. // and normal in the camera space) should be taken as texture coordinates
  1225. // Low 16 bits are used to specify texture coordinate index, to take the WRAP mode from
  1226. //
  1227. #define D3DTSS_TCI_PASSTHRU                             0x00000000
  1228. #define D3DTSS_TCI_CAMERASPACENORMAL                    0x00010000
  1229. #define D3DTSS_TCI_CAMERASPACEPOSITION                  0x00020000
  1230. #define D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR          0x00030000
  1231.  
  1232. /*
  1233.  * Enumerations for COLOROP and ALPHAOP texture blending operations set in
  1234.  * texture processing stage controls in D3DRENDERSTATE.
  1235.  */
  1236. typedef enum _D3DTEXTUREOP
  1237. {
  1238. // Control
  1239.     D3DTOP_DISABLE    = 1,      // disables stage
  1240.     D3DTOP_SELECTARG1 = 2,      // the default
  1241.     D3DTOP_SELECTARG2 = 3,
  1242.  
  1243. // Modulate
  1244.     D3DTOP_MODULATE   = 4,      // multiply args together
  1245.     D3DTOP_MODULATE2X = 5,      // multiply and  1 bit
  1246.     D3DTOP_MODULATE4X = 6,      // multiply and  2 bits
  1247.  
  1248. // Add
  1249.     D3DTOP_ADD          =  7,   // add arguments together
  1250.     D3DTOP_ADDSIGNED    =  8,   // add with -0.5 bias
  1251.     D3DTOP_ADDSIGNED2X  =  9,   // as above but left  1 bit
  1252.     D3DTOP_SUBTRACT     = 10,   // Arg1 - Arg2, with no saturation
  1253.     D3DTOP_ADDSMOOTH    = 11,   // add 2 args, subtract product
  1254.                                 // Arg1 + Arg2 - Arg1*Arg2
  1255.                                 // = Arg1 + (1-Arg1)*Arg2
  1256.  
  1257. // Linear alpha blend: Arg1*(Alpha) + Arg2*(1-Alpha)
  1258.     D3DTOP_BLENDDIFFUSEALPHA    = 12, // iterated alpha
  1259.     D3DTOP_BLENDTEXTUREALPHA    = 13, // texture alpha
  1260.     D3DTOP_BLENDFACTORALPHA     = 14, // alpha from D3DRENDERSTATE_TEXTUREFACTOR
  1261.     // Linear alpha blend with pre-multiplied arg1 input: Arg1 + Arg2*(1-Alpha)
  1262.     D3DTOP_BLENDTEXTUREALPHAPM  = 15, // texture alpha
  1263.     D3DTOP_BLENDCURRENTALPHA    = 16, // by alpha of current color
  1264.  
  1265. // Specular mapping
  1266.     D3DTOP_PREMODULATE            = 17,     // modulate with next texture before use
  1267.     D3DTOP_MODULATEALPHA_ADDCOLOR = 18,     // Arg1.RGB + Arg1.A*Arg2.RGB
  1268.                                             // COLOROP only
  1269.     D3DTOP_MODULATECOLOR_ADDALPHA = 19,     // Arg1.RGB*Arg2.RGB + Arg1.A
  1270.                                             // COLOROP only
  1271.     D3DTOP_MODULATEINVALPHA_ADDCOLOR = 20,  // (1-Arg1.A)*Arg2.RGB + Arg1.RGB
  1272.                                             // COLOROP only
  1273.     D3DTOP_MODULATEINVCOLOR_ADDALPHA = 21,  // (1-Arg1.RGB)*Arg2.RGB + Arg1.A
  1274.                                             // COLOROP only
  1275.  
  1276. // Bump mapping
  1277.     D3DTOP_BUMPENVMAP           = 22, // per pixel env map perturbation
  1278.     D3DTOP_BUMPENVMAPLUMINANCE  = 23, // with luminance channel
  1279.     // This can do either diffuse or specular bump mapping with correct input.
  1280.     // Performs the function (Arg1.R*Arg2.R + Arg1.G*Arg2.G + Arg1.B*Arg2.B)
  1281.     // where each component has been scaled and offset to make it signed.
  1282.     // The result is replicated into all four (including alpha) channels.
  1283.     // This is a valid COLOROP only.
  1284.     D3DTOP_DOTPRODUCT3          = 24,
  1285.  
  1286.     D3DTOP_FORCE_DWORD = 0x7fffffff,
  1287. } D3DTEXTUREOP;
  1288.  
  1289. /*
  1290.  * Values for COLORARG1,2 and ALPHAARG1,2 texture blending operations
  1291.  * set in texture processing stage controls in D3DRENDERSTATE.
  1292.  */
  1293. #define D3DTA_SELECTMASK        0x0000000f  // mask for arg selector
  1294. #define D3DTA_DIFFUSE           0x00000000  // select diffuse color
  1295. #define D3DTA_CURRENT           0x00000001  // select result of previous stage
  1296. #define D3DTA_TEXTURE           0x00000002  // select texture color
  1297. #define D3DTA_TFACTOR           0x00000003  // select RENDERSTATE_TEXTUREFACTOR
  1298. #define D3DTA_SPECULAR          0x00000004  // select specular color
  1299. #define D3DTA_COMPLEMENT        0x00000010  // take 1.0 - x
  1300. #define D3DTA_ALPHAREPLICATE    0x00000020  // replicate alpha to color components
  1301.  
  1302.  
  1303. /*
  1304.  *  IDirect3DTexture2 State Filter Types
  1305.  */
  1306. typedef enum _D3DTEXTUREMAGFILTER
  1307. {
  1308.     D3DTFG_POINT        = 1,    // nearest
  1309.     D3DTFG_LINEAR       = 2,    // linear interpolation
  1310.     D3DTFG_FLATCUBIC    = 3,    // cubic
  1311.     D3DTFG_GAUSSIANCUBIC = 4,   // different cubic kernel
  1312.     D3DTFG_ANISOTROPIC  = 5,    //
  1313.     D3DTFG_FORCE_DWORD  = 0x7fffffff,   // force 32-bit size enum
  1314. } D3DTEXTUREMAGFILTER;
  1315.  
  1316. typedef enum _D3DTEXTUREMINFILTER
  1317. {
  1318.     D3DTFN_POINT        = 1,    // nearest
  1319.     D3DTFN_LINEAR       = 2,    // linear interpolation
  1320.     D3DTFN_ANISOTROPIC  = 3,    //
  1321.     D3DTFN_FORCE_DWORD  = 0x7fffffff,   // force 32-bit size enum
  1322. } D3DTEXTUREMINFILTER;
  1323.  
  1324. typedef enum _D3DTEXTUREMIPFILTER
  1325. {
  1326.     D3DTFP_NONE         = 1,    // mipmapping disabled (use MAG filter)
  1327.     D3DTFP_POINT        = 2,    // nearest
  1328.     D3DTFP_LINEAR       = 3,    // linear interpolation
  1329.     D3DTFP_FORCE_DWORD  = 0x7fffffff,   // force 32-bit size enum
  1330. } D3DTEXTUREMIPFILTER;
  1331.  
  1332. /*
  1333.  * Triangle flags
  1334.  */
  1335.  
  1336. /*
  1337.  * Tri strip and fan flags.
  1338.  * START loads all three vertices
  1339.  * EVEN and ODD load just v3 with even or odd culling
  1340.  * START_FLAT contains a count from 0 to 29 that allows the
  1341.  * whole strip or fan to be culled in one hit.
  1342.  * e.g. for a quad len = 1
  1343.  */
  1344. #define D3DTRIFLAG_START            0x00000000L
  1345. #define D3DTRIFLAG_STARTFLAT(len) (len)     /* 0 < len < 30 */
  1346. #define D3DTRIFLAG_ODD              0x0000001eL
  1347. #define D3DTRIFLAG_EVEN             0x0000001fL
  1348.  
  1349. /*
  1350.  * Triangle edge flags
  1351.  * enable edges for wireframe or antialiasing
  1352.  */
  1353. #define D3DTRIFLAG_EDGEENABLE1          0x00000100L /* v0-v1 edge */
  1354. #define D3DTRIFLAG_EDGEENABLE2          0x00000200L /* v1-v2 edge */
  1355. #define D3DTRIFLAG_EDGEENABLE3          0x00000400L /* v2-v0 edge */
  1356. #define D3DTRIFLAG_EDGEENABLETRIANGLE \
  1357.         (D3DTRIFLAG_EDGEENABLE1 | D3DTRIFLAG_EDGEENABLE2 | D3DTRIFLAG_EDGEENABLE3)
  1358.  
  1359. /*
  1360.  * Primitive structures and related defines.  Vertex offsets are to types
  1361.  * D3DVERTEX, D3DLVERTEX, or D3DTLVERTEX.
  1362.  */
  1363.  
  1364. /*
  1365.  * Triangle list primitive structure
  1366.  */
  1367. typedef struct _D3DTRIANGLE {
  1368.     union {
  1369.     WORD    v1;            /* Vertex indices */
  1370.     WORD    wV1;
  1371.     };
  1372.     union {
  1373.     WORD    v2;
  1374.     WORD    wV2;
  1375.     };
  1376.     union {
  1377.     WORD    v3;
  1378.     WORD    wV3;
  1379.     };
  1380.     WORD        wFlags;       /* Edge (and other) flags */
  1381. } D3DTRIANGLE, *LPD3DTRIANGLE;
  1382.  
  1383. /*
  1384.  * Line list structure.
  1385.  * The instruction count defines the number of line segments.
  1386.  */
  1387. typedef struct _D3DLINE {
  1388.     union {
  1389.     WORD    v1;            /* Vertex indices */
  1390.     WORD    wV1;
  1391.     };
  1392.     union {
  1393.     WORD    v2;
  1394.     WORD    wV2;
  1395.     };
  1396. } D3DLINE, *LPD3DLINE;
  1397.  
  1398. /*
  1399.  * Span structure
  1400.  * Spans join a list of points with the same y value.
  1401.  * If the y value changes, a new span is started.
  1402.  */
  1403. typedef struct _D3DSPAN {
  1404.     WORD    wCount; /* Number of spans */
  1405.     WORD    wFirst; /* Index to first vertex */
  1406. } D3DSPAN, *LPD3DSPAN;
  1407.  
  1408. /*
  1409.  * Point structure
  1410.  */
  1411. typedef struct _D3DPOINT {
  1412.     WORD    wCount;     /* number of points     */
  1413.     WORD    wFirst;     /* index to first vertex    */
  1414. } D3DPOINT, *LPD3DPOINT;
  1415.  
  1416.  
  1417. /*
  1418.  * Forward branch structure.
  1419.  * Mask is logically anded with the driver status mask
  1420.  * if the result equals 'value', the branch is taken.
  1421.  */
  1422. typedef struct _D3DBRANCH {
  1423.     DWORD   dwMask;     /* Bitmask against D3D status */
  1424.     DWORD   dwValue;
  1425.     BOOL    bNegate;        /* TRUE to negate comparison */
  1426.     DWORD   dwOffset;   /* How far to branch forward (0 for exit)*/
  1427. } D3DBRANCH, *LPD3DBRANCH;
  1428.  
  1429. /*
  1430.  * Status used for set status instruction.
  1431.  * The D3D status is initialised on device creation
  1432.  * and is modified by all execute calls.
  1433.  */
  1434. typedef struct _D3DSTATUS {
  1435.     DWORD       dwFlags;    /* Do we set extents or status */
  1436.     DWORD   dwStatus;   /* D3D status */
  1437.     D3DRECT drExtent;
  1438. } D3DSTATUS, *LPD3DSTATUS;
  1439.  
  1440. #define D3DSETSTATUS_STATUS     0x00000001L
  1441. #define D3DSETSTATUS_EXTENTS        0x00000002L
  1442. #define D3DSETSTATUS_ALL    (D3DSETSTATUS_STATUS | D3DSETSTATUS_EXTENTS)
  1443.  
  1444. typedef struct _D3DCLIPSTATUS {
  1445.     DWORD dwFlags; /* Do we set 2d extents, 3D extents or status */
  1446.     DWORD dwStatus; /* Clip status */
  1447.     float minx, maxx; /* X extents */
  1448.     float miny, maxy; /* Y extents */
  1449.     float minz, maxz; /* Z extents */
  1450. } D3DCLIPSTATUS, *LPD3DCLIPSTATUS;
  1451.  
  1452. #define D3DCLIPSTATUS_STATUS        0x00000001L
  1453. #define D3DCLIPSTATUS_EXTENTS2      0x00000002L
  1454. #define D3DCLIPSTATUS_EXTENTS3      0x00000004L
  1455.  
  1456. /*
  1457.  * Statistics structure
  1458.  */
  1459. typedef struct _D3DSTATS {
  1460.     DWORD        dwSize;
  1461.     DWORD        dwTrianglesDrawn;
  1462.     DWORD        dwLinesDrawn;
  1463.     DWORD        dwPointsDrawn;
  1464.     DWORD        dwSpansDrawn;
  1465.     DWORD        dwVerticesProcessed;
  1466. } D3DSTATS, *LPD3DSTATS;
  1467.  
  1468. /*
  1469.  * Execute options.
  1470.  * When calling using D3DEXECUTE_UNCLIPPED all the primitives
  1471.  * inside the buffer must be contained within the viewport.
  1472.  */
  1473. #define D3DEXECUTE_CLIPPED       0x00000001l
  1474. #define D3DEXECUTE_UNCLIPPED     0x00000002l
  1475.  
  1476. typedef struct _D3DEXECUTEDATA {
  1477.     DWORD       dwSize;
  1478.     DWORD       dwVertexOffset;
  1479.     DWORD       dwVertexCount;
  1480.     DWORD       dwInstructionOffset;
  1481.     DWORD       dwInstructionLength;
  1482.     DWORD       dwHVertexOffset;
  1483.     D3DSTATUS   dsStatus;   /* Status after execute */
  1484. } D3DEXECUTEDATA, *LPD3DEXECUTEDATA;
  1485.  
  1486. /*
  1487.  * Palette flags.
  1488.  * This are or'ed with the peFlags in the PALETTEENTRYs passed to DirectDraw.
  1489.  */
  1490. #define D3DPAL_FREE 0x00    /* Renderer may use this entry freely */
  1491. #define D3DPAL_READONLY 0x40    /* Renderer may not set this entry */
  1492. #define D3DPAL_RESERVED 0x80    /* Renderer may not use this entry */
  1493.  
  1494.  
  1495.  
  1496. typedef struct _D3DVERTEXBUFFERDESC {
  1497.     DWORD dwSize;
  1498.     DWORD dwCaps;
  1499.     DWORD dwFVF;
  1500.     DWORD dwNumVertices;
  1501. } D3DVERTEXBUFFERDESC, *LPD3DVERTEXBUFFERDESC;
  1502.  
  1503. #define D3DVBCAPS_SYSTEMMEMORY      0x00000800l
  1504. #define D3DVBCAPS_WRITEONLY         0x00010000l
  1505. #define D3DVBCAPS_OPTIMIZED         0x80000000l
  1506. #define D3DVBCAPS_DONOTCLIP         0x00000001l
  1507.  
  1508. /* Vertex Operations for ProcessVertices */
  1509. #define D3DVOP_LIGHT       (1 << 10)
  1510. #define D3DVOP_TRANSFORM   (1 << 0)
  1511. #define D3DVOP_CLIP        (1 << 2)
  1512. #define D3DVOP_EXTENTS     (1 << 3)
  1513.  
  1514. /* The maximum number of vertices user can pass to any d3d
  1515.    drawing function or to create vertex buffer with
  1516. */
  1517. #define D3DMAXNUMVERTICES    ((1<<16) - 1)
  1518. /* The maximum number of primitives user can pass to any d3d
  1519.    drawing function.
  1520. */
  1521. #define D3DMAXNUMPRIMITIVES  ((1<<16) - 1)
  1522.  
  1523. /* Bits for dwFlags in ProcessVertices call */
  1524. #define D3DPV_DONOTCOPYDATA (1 << 0)
  1525.  
  1526. //-------------------------------------------------------------------
  1527.  
  1528. // Flexible vertex format bits
  1529. //
  1530. #define D3DFVF_RESERVED0        0x001
  1531. #define D3DFVF_POSITION_MASK    0x00E
  1532. #define D3DFVF_XYZ              0x002
  1533. #define D3DFVF_XYZRHW           0x004
  1534. #define D3DFVF_XYZB1            0x006
  1535. #define D3DFVF_XYZB2            0x008
  1536. #define D3DFVF_XYZB3            0x00a
  1537. #define D3DFVF_XYZB4            0x00c
  1538. #define D3DFVF_XYZB5            0x00e
  1539.  
  1540. #define D3DFVF_NORMAL           0x010
  1541. #define D3DFVF_RESERVED1        0x020
  1542. #define D3DFVF_DIFFUSE          0x040
  1543. #define D3DFVF_SPECULAR         0x080
  1544.  
  1545. #define D3DFVF_TEXCOUNT_MASK    0xf00
  1546. #define D3DFVF_TEXCOUNT_SHIFT   8
  1547. #define D3DFVF_TEX0             0x000
  1548. #define D3DFVF_TEX1             0x100
  1549. #define D3DFVF_TEX2             0x200
  1550. #define D3DFVF_TEX3             0x300
  1551. #define D3DFVF_TEX4             0x400
  1552. #define D3DFVF_TEX5             0x500
  1553. #define D3DFVF_TEX6             0x600
  1554. #define D3DFVF_TEX7             0x700
  1555. #define D3DFVF_TEX8             0x800
  1556.  
  1557. #define D3DFVF_RESERVED2        0xf000  // 4 reserved bits
  1558.  
  1559. #define D3DFVF_VERTEX ( D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1 )
  1560. #define D3DFVF_LVERTEX ( D3DFVF_XYZ | D3DFVF_RESERVED1 | D3DFVF_DIFFUSE | \
  1561.                          D3DFVF_SPECULAR | D3DFVF_TEX1 )
  1562. #define D3DFVF_TLVERTEX ( D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | \
  1563.                           D3DFVF_TEX1 )
  1564.  
  1565. typedef struct _D3DDP_PTRSTRIDE
  1566. {
  1567.     LPVOID lpvData;
  1568.     DWORD  dwStride;
  1569. } D3DDP_PTRSTRIDE;
  1570.  
  1571. #define D3DDP_MAXTEXCOORD 8
  1572.  
  1573. typedef struct _D3DDRAWPRIMITIVESTRIDEDDATA
  1574. {
  1575.     D3DDP_PTRSTRIDE position;
  1576.     D3DDP_PTRSTRIDE normal;
  1577.     D3DDP_PTRSTRIDE diffuse;
  1578.     D3DDP_PTRSTRIDE specular;
  1579.     D3DDP_PTRSTRIDE textureCoords[D3DDP_MAXTEXCOORD];
  1580. } D3DDRAWPRIMITIVESTRIDEDDATA, *LPD3DDRAWPRIMITIVESTRIDEDDATA;
  1581. //---------------------------------------------------------------------
  1582. // ComputeSphereVisibility return values
  1583. //
  1584. #define D3DVIS_INSIDE_FRUSTUM       0
  1585. #define D3DVIS_INTERSECT_FRUSTUM    1
  1586. #define D3DVIS_OUTSIDE_FRUSTUM      2
  1587. #define D3DVIS_INSIDE_LEFT          0
  1588. #define D3DVIS_INTERSECT_LEFT       (1 << 2)
  1589. #define D3DVIS_OUTSIDE_LEFT         (2 << 2)
  1590. #define D3DVIS_INSIDE_RIGHT         0
  1591. #define D3DVIS_INTERSECT_RIGHT      (1 << 4)
  1592. #define D3DVIS_OUTSIDE_RIGHT        (2 << 4)
  1593. #define D3DVIS_INSIDE_TOP           0
  1594. #define D3DVIS_INTERSECT_TOP        (1 << 6)
  1595. #define D3DVIS_OUTSIDE_TOP          (2 << 6)
  1596. #define D3DVIS_INSIDE_BOTTOM        0
  1597. #define D3DVIS_INTERSECT_BOTTOM     (1 << 8)
  1598. #define D3DVIS_OUTSIDE_BOTTOM       (2 << 8)
  1599. #define D3DVIS_INSIDE_NEAR          0
  1600. #define D3DVIS_INTERSECT_NEAR       (1 << 10)
  1601. #define D3DVIS_OUTSIDE_NEAR         (2 << 10)
  1602. #define D3DVIS_INSIDE_FAR           0
  1603. #define D3DVIS_INTERSECT_FAR        (1 << 12)
  1604. #define D3DVIS_OUTSIDE_FAR          (2 << 12)
  1605.  
  1606. #define D3DVIS_MASK_FRUSTUM         (3 << 0)
  1607. #define D3DVIS_MASK_LEFT            (3 << 2)
  1608. #define D3DVIS_MASK_RIGHT           (3 << 4)
  1609. #define D3DVIS_MASK_TOP             (3 << 6)
  1610. #define D3DVIS_MASK_BOTTOM          (3 << 8)
  1611. #define D3DVIS_MASK_NEAR            (3 << 10)
  1612. #define D3DVIS_MASK_FAR             (3 << 12)
  1613.  
  1614.  
  1615. // To be used with GetInfo()
  1616. #define D3DDEVINFOID_TEXTUREMANAGER    1
  1617. #define D3DDEVINFOID_D3DTEXTUREMANAGER 2
  1618. #define D3DDEVINFOID_TEXTURING         3
  1619.  
  1620. typedef enum _D3DSTATEBLOCKTYPE
  1621. {
  1622.     D3DSBT_ALL           = 1, // capture all state
  1623.     D3DSBT_PIXELSTATE    = 2, // capture pixel state
  1624.     D3DSBT_VERTEXSTATE   = 3, // capture vertex state
  1625.     D3DSBT_FORCE_DWORD   = 0xffffffff
  1626. } D3DSTATEBLOCKTYPE;
  1627.  
  1628. // The D3DVERTEXBLENDFLAGS type is used with D3DRENDERSTATE_VERTEXBLEND state.
  1629. //
  1630. typedef enum _D3DVERTEXBLENDFLAGS
  1631. {
  1632.     D3DVBLEND_DISABLE  = 0, // Disable vertex blending
  1633.     D3DVBLEND_1WEIGHT  = 1, // blend between 2 matrices
  1634.     D3DVBLEND_2WEIGHTS = 2, // blend between 3 matrices
  1635.     D3DVBLEND_3WEIGHTS = 3, // blend between 4 matrices
  1636. } D3DVERTEXBLENDFLAGS;
  1637.  
  1638. typedef enum _D3DTEXTURETRANSFORMFLAGS {
  1639.     D3DTTFF_DISABLE         = 0,    // texture coordinates are passed directly
  1640.     D3DTTFF_COUNT1          = 1,    // rasterizer should expect 1-D texture coords
  1641.     D3DTTFF_COUNT2          = 2,    // rasterizer should expect 2-D texture coords
  1642.     D3DTTFF_COUNT3          = 3,    // rasterizer should expect 3-D texture coords
  1643.     D3DTTFF_COUNT4          = 4,    // rasterizer should expect 4-D texture coords
  1644.     D3DTTFF_PROJECTED       = 256,  // texcoords to be divided by COUNTth element
  1645.     D3DTTFF_FORCE_DWORD     = 0x7fffffff,
  1646. } D3DTEXTURETRANSFORMFLAGS;
  1647.  
  1648. // Macros to set texture coordinate format bits in the FVF id
  1649.  
  1650. #define D3DFVF_TEXTUREFORMAT2 0         // Two floating point values
  1651. #define D3DFVF_TEXTUREFORMAT1 3         // One floating point value
  1652. #define D3DFVF_TEXTUREFORMAT3 1         // Three floating point values
  1653. #define D3DFVF_TEXTUREFORMAT4 2         // Four floating point values
  1654.  
  1655. #define D3DFVF_TEXCOORDSIZE3(CoordIndex) (D3DFVF_TEXTUREFORMAT3 << (CoordIndex*2 + 16))
  1656. #define D3DFVF_TEXCOORDSIZE2(CoordIndex) (D3DFVF_TEXTUREFORMAT2)
  1657. #define D3DFVF_TEXCOORDSIZE4(CoordIndex) (D3DFVF_TEXTUREFORMAT4 << (CoordIndex*2 + 16))
  1658. #define D3DFVF_TEXCOORDSIZE1(CoordIndex) (D3DFVF_TEXTUREFORMAT1 << (CoordIndex*2 + 16))
  1659.  
  1660.  
  1661. #endif /* _D3DTYPES_H_ */
  1662.  
  1663.